<?php
// calcul du port
	function port($type=0){

		if($_SESSION['navig']->commande->transport == "" && !$type) return -1;

		if( $_SESSION['navig']->adresse != 0) $chadr=1;
		else $chadr=0;

		$modules = new Modules();

		if(!$type) $modules->charger_id($_SESSION['navig']->commande->transport);
		else $modules->charger_id($type);

		if($modules->type != "2" || ! $modules->actif) return -1;

		$p = new Pays();
		if($chadr){
			 $adr = new adresse();
			 $adr->charger($_SESSION['navig']->adresse);
			 $p->charger($adr->pays);
			 $cpostal = $adr->cpostal;
		}
		else {
			$p->charger($_SESSION['navig']->client->pays);
			$cpostal = $_SESSION['navig']->client->cpostal;
		}

		$zone = new Zone();
		$zone->charger($p->zone);

		try {
			$port = ActionsModules::instance()->instancier($modules->nom);

			$port->nbart = $_SESSION['navig']->panier->nbart();
			$port->poids = $_SESSION['navig']->panier->poids();
			$port->total = $_SESSION['navig']->panier->total();
			$port->zone = $p->zone;
			$port->pays = $p->id;
			$port->unitetr = $zone->unite;
			$port->cpostal = $cpostal;

			return $port->calcule();

		} catch (Exception $e) {
			return -1;
		}
	}

?>